package com.zr.config;

import com.zr.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;

/**
 * 登录认证拦截器配置
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private AuthorizationInterceptor authorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器对象
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(authorizationInterceptor);
        //配置拦截规则和排除拦截的请求地址
        interceptorRegistration.addPathPatterns("/**").excludePathPatterns("/sys/user/login","/driver/login");
    }
}
